<template>
  <el-card shadow="never">
    <e-table
      ref="eTable"
      @getList="handleGetList"
      :tableData="tableData"
      :columns="columns"
      :loading="loading"
      :total="total"
    />
  </el-card>
</template>

<script>
import { getBigChkNegPosMonitor } from '@/api/reports'
export default {
  data() {
    return {
      total: 1,
      loading: false,
      tableData: [],
      columns: [],
      queryParam: {
        pageSize: 10,
        pageNo: 1
      }
    }
  },
  methods: {
    //columns 动态删减，根据form传递过来的数据
    async handleGetList(param = {}) {
      this.loading = true
      this.columns = [
        {
          label: '检查人数',
          prop: 'chk_person_num'
        },
        {
          label: '阳性人数',
          prop: 'pos_num'
        },
        {
          label: '阳性率',
          prop: 'pos_rate',
          formatter: function(row, column, cellValue, index) {
            return row.pos_rate ? row.pos_rate + '%' : null
          }
        }
      ]
      this.queryParam = Object.assign(this.queryParam, param)
      if (this.queryParam.docNameState) {
        this.columns.unshift({
          label: '医生名称',
          prop: 'bill_his_doctor'
        })
      }
      if (this.queryParam.deptState) {
        this.columns.unshift({
          label: '科室名称',
          prop: 'his_dept_name'
        })
      }
      if (this.queryParam.dateState) {
        this.columns.unshift({
          label: '日期',
          prop: 'dt'
        })
      }
      const res = await getBigChkNegPosMonitor(this.queryParam)
      if (res && res.data.records.length > 0) {
        const {
          state,
          data: { records, total }
        } = res
        this.tableData = records
        this.total = total
      } else {
        this.tableData = []
        this.total = 1
      }
      this.loading = false
    }
  }
}
</script>
